package com.hey.baseapplication.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.Button;

import com.hey.baseapplication.R;
import com.hey.baseapplication.fragment.MainFragment;
import com.hey.baseapplication.fragment.QRCodeFragment;
import com.hey.baseapplication.view.IMainView;

public class MainActivity extends BaseActivity implements IMainView{
    private Button mainButton,publishButton,orderButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setTitle("Main");
        initView();
        ChangeFragment(new MainFragment());
    }

    @Override
    protected void findView() {
        mainButton= (Button) findViewById(R.id.homepage);
        publishButton= (Button) findViewById(R.id.publish);
        orderButton= (Button) findViewById(R.id.order);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {

        mainButton.setOnClickListener(this);
        publishButton.setOnClickListener(this);
        orderButton.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
    switch (view.getId()){
        case R.id.homepage:
            setTitle("main");
            ChangeFragment(new MainFragment());
            break;
        case R.id.publish:
            setTitle("QRCode");
            ChangeFragment(new QRCodeFragment());
            break;
        case  R.id.order:

            break;


    }
    }

    @Override
    public void ChangeFragment(Fragment fragment) {
        getSupportFragmentManager().beginTransaction().replace(R.id.main_view,fragment).commit();

    }

    @Override
    public void publishEvent() {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void next() {

    }
}
